<template>
	<view class="content">
		<view class="entry-content">
			<view>提现金额</view>
			<view>
				￥
				<input type="number" value="" v-model="money" />
			</view>
			<view>可用余额 {{y}}元,手续费:{{result_fee}}</view>
		</view>
		
		<view class="title">选择收款方式</view>
		<view class="e_item">
			<view class="select_box" @click="typeChange('1')">
				<view class="iconfont icon ali">&#xe68a;</view>
				<view class="txt">支付宝</view>
				<view class="iconfont icon2" :class="type == '1' ? 'icon_s':''">&#xe626;</view>
			</view>
			<view class="select_box" @click="typeChange('2')">
				<view class="iconfont3 icon bank">&#xe936;</view>
				<view class="txt">银行卡</view>
				<view class="iconfont icon2" :class="type == '2' ? 'icon_s':''">&#xe626;</view>
			</view>
		</view>
		
		<view class="e_item">
			<view class="e_title">
				<block v-if="type == '2'">
					<label class="iconfont3 icon_bank">&#xe936;</label>提现到银行卡
				</block>
				<block v-if="type == '1'">
					<label class="iconfont icon_ali">&#xe68a;</label>提现到支付宝
				</block>
			</view>
			<block v-if="type == '1'">
				<view class="e_box">
					<view class="e_tit">姓名</view>
					<input class="e_input" type="text" v-model="us.zfb_name" disabled>
				</view>
				<view class="e_box">
					<view class="e_tit">支付宝账号</view>
					<input class="e_input" type="text" v-model="us.zfb" disabled>
				</view>
			</block>
			<block v-if="type == '2'">
				<view class="e_box">
					<view class="e_tit">银行名称</view>
					<input class="e_input" type="text" v-model="us.bank_type" disabled>
				</view>
				<view class="e_box">
					<view class="e_tit">预留姓名</view>
					<input class="e_input" type="text" v-model="us.bank_name" disabled>
				</view>
				<view class="e_box">
					<view class="e_tit">预留电话</view>
					<input class="e_input" type="text" v-model="us.bank_phone" disabled>
				</view>
				<view class="e_box">
					<view class="e_tit">银行卡号</view>
					<input class="e_input" type="text" v-model="us.bank_card" disabled>
				</view>
			</block>
			<view class="noBing" v-if="type == '2'"><label @click="gotopage" data-url="/pages/personal/bank/bank">去绑定/修改</label></view>
			<view class="noBing" v-if="type == '1'"><label @click="gotopage" data-url="/pages/personal/bank/bank1">去绑定/修改</label></view>
		</view>
		<view style="padding-bottom: 10vh;width: 100%;"></view>
		<!-- 	<view class="list_box">
		<view class="list">
				<picker @change="GenderChange" :value="b_index" :range="bank">
					<view class="title">选择提现银行卡</view>
					<input disabled="true" type="text" value="" placeholder="请选择" v-model="gender" />

				</picker>
			</view>
		</view>

		<view class="ad_item">
			<view class="ad_img_item">
				<swiper class="ad_swiper_box" :circular="true" :autoplay="true" :interval="3000" :duration="200" indicator-dots="true" indicator-color="#d1d1d1" indicator-active-color="#444444">
					<block v-for="(item, index) in adImgArr" :key="'ad_'+index">
						<swiper-item class="ad_s_box"  :data-item="item"  @click="gotopage3">
							<image class="ad_img" :src="item.image"></image>
						</swiper-item>
					</block>
				</swiper>
			</view>
		</view> -->

		<!-- <view class="pay-content">
			<view class="title">选择支付方式</view>
			<view class="body">
				<block v-for="(item,index) in payList" :key="index">
					<view class="pay-item" @click="selPay(index)">
						<view class="left">
							<view class="iconfont" :class="item.class"></view>
							<view>{{item.name}}</view>
						</view>
						
						<view class="right iconfont" :class="isSel==index ? 'icondagouwancheng' : '' "></view>
					</view>
				</block>
			</view>
		</view> -->

		<view class="btn" @tap="go()">提现</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				adImgArr:[],
				money: '',
				y: 0,
				tickSelected: 1,
				f: false,
				zfb: null,
				sx: 0,
					fp_sx: 0,
				bank: [],
				gender:'',
				b_index:0,
				us:'',
				ali_account:'',
				ali_name:'',
				
				type:'2',    //0支付宝   1 微信    2银行
			};
		},
		onShow() {
			let me = this;

			me.Net._get('h5', {}, (res) => {
				if (res.code == 1) {

					if (res.data.bank) {
						me.f = true
					}
						
					me.y = res.data.y
					me.sx = res.data.sx
						me.us = res.data.us
				
				// 	if(me.bank.length==0)
				// 	{
				// 		me.Msg.Fail('请先绑定银行卡',(res)=>{
				// 		me.Nav._to({url:'/pages/personal/bank/bank',type:1})
				// 		})
				// 	}
					console.log(res.data)
				}
			});
		},
		methods: {
			typeChange(_type){
				this.type = _type;
			},
			gotopage(e){
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url:url
				})
			},
			go() {
				var that = this;
				if (!that.money) {
					that.Msg.Fail('请输入金额');
					return
				}
				if (parseFloat(that.money) > parseFloat(that.y)) {
					that.Msg.Fail('提现金额大于余额');
					return
				}
				// if (!that.ali_account || !that.ali_name) {
				// 	that.Msg.Fail('请填写支付宝信息');
				// 	return
				// }
				// if (!that.bank) {
				// 	that.Msg.Fail('请先绑定银行卡', (res) => {
				// 		uni.navigateTo({
				// 			url: "/pages/personal/bank/bank"
				// 		})
				// 	})
				// 	return
				// }
				// if (!that.gender) {
				// 	that.Msg.Fail('请选择银行卡');
				// 	return
				// }
				console.log(that.data)
				that.Net._get('carry_new', {
					money: that.money,
					type:that.type
				
				}, (res) => {
					if (res.code == 1) {
						that.Msg.Success('提交成功,等待审核', (res) => {
							uni.navigateBack({
								delta: 1
							})
						})
					}
				});
			},
			tickColor(id) {
				if (this.tickSelected == id) {
					return false
				} else {
					this.tickSelected = id;

				}
			},
			selPay(e) {
				// console.log(e,this.isSel)
				this.isSel = e;
			},
			GenderChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value);
				this.b_index = e.target.value;
				this.gender = this.bank[e.target.value];
			},
			gotopage3(e){
				let item = e.currentTarget.dataset.item;
				this.gotopage1(item);
			},
			gotopage1(item) {
						var that = this;
						if (item.type == 1) {
							uni.navigateTo({
								url: '/pages/goods/goods?id=' + item.t_id
							});
						} else if (item.type == 2) {
							uni.navigateTo({
								url: '/pages/news/news?type=' + item.t_id
							});
							
						} 
						else if (item.type == 3) {
							uni.navigateTo({
								url: '/pages/list/list?cid=' + item.t_id
							});
							
						} 
						else if (item.type == 4) {
							uni.navigateTo({
								url: '/pages/list/list?type=' + item.t_id
							});
						
						} 
						else if (item.type == 5) {
							uni.navigateTo({
								url: '/pages/list/list?marks=' + item.t_id
							});	
							}
						else {
							return;
						}
					}
		},
		computed:{
			result_fee(){
				if(!this.money || this.money == '' || Number(this.money) == 0){
					return '0.00'
				}else{
					let res = this.money*this.sx*0.01;
					return res.toFixed(2);
				}
			},
			result_fqfee(){
				if(!this.money || this.money == '' || Number(this.money) == 0){
					return '0.00'
				}else{
					let res = this.money*this.fp_sx*0.01;
					return res.toFixed(2);
				}
			}
		}
	};
</script>
<style lang="scss">
	@import '@/static/iconfont/iconfont.css';
	page{
		background-color: #f8f8f8;
	}
	
	.ad_item{
		width: 100%;
		.ad_img_item{
			width: 100%;
			height: 320rpx;
			position: relative;
			z-index: 3;
			padding: 0 30rpx;
			margin-top: 30rpx;
			margin-bottom: 20rpx;
			display: inline-block;
			.ad_swiper_box{
				width: 100%;
				height: 100%;
				border-radius: 15rpx;
				overflow: hidden;
				.ad_s_box{
					width: 100%;
					height: 100%;
					.ad_img{
						width: 100%;
						height: 100%;
					}
				}
			}
		}
	}
	
	.content {
		overflow: hidden;
		padding-bottom: 20rpx;
		.title{
			padding: 50rpx 30rpx 0;
			width: 100%;
			font-size: 32rpx;
			font-weight: bold;
		}
	}

	.entry-content {
		width: 690rpx;
		// height: 370rpx;
		background-color: #ffffff;
		box-shadow: 0 0 4rpx 2rpx #f6f6f6;
		border-radius: 20rpx;
		margin: 30rpx auto 0;
		box-shadow:  0 0 10rpx #dddddd; 
		view {
			font-size: 30rpx;
			font-weight: 500;
			width: 90%;
			margin: 0 auto;

			&:nth-child(1) {
				color: #666666;
				padding: 50rpx 0;
			}

			&:nth-child(2) {
				font-size: 60rpx;
				color: #1d1d1d;
				margin-top: 20rpx;
				padding: 30rpx 0;
				display: flex;
				align-items: center;

				input {
					font-size: 60rpx;
					color: #1d1d1d;
					margin-left: 30rpx;
				}
			}

			&:nth-child(3) {
				color: #767676;
				padding: 30rpx 0;
				border-top: 1px solid #f7f7f7;
			}
		}
	}
	
	.e_item{
		width: 690rpx;
		// height: 370rpx;
		background-color: #ffffff;
		box-shadow: 0 0 4rpx 2rpx #f6f6f6;
		border-radius: 20rpx;
		margin: 30rpx auto 0;
		box-shadow:  0 0 10rpx #dddddd; 
		padding-bottom: 40rpx;
		.e_title{
			font-size: 30rpx;
			font-weight: 500;
			padding: 50rpx 5% 10rpx;
			display: flex;
			align-items: center;
			.icon_ali{
				font-size: 50rpx;
				color: #01aaef;
				padding-right: 10rpx;
			}
			.icon_bank{
				font-size: 50rpx;
				color: #0066ff;
				padding-right: 10rpx;
			}
		}
		.e_box{
			padding: 0 5%;
			display: flex;
			align-items: center;
			margin-top: 30rpx;
			.e_tit{
				font-size: 30rpx;
				font-weight: bold;
				color: #666666;
				width: 200rpx;
			}
			.e_input{
				height: 10vw;
				padding: 1vw 3vw;
				flex: 1;
				background: #fafafa;
				text-align: right;
				border-radius: 15rpx;
				color: #666666;
			}
		}
		.noBing{
			width: 100%;
			padding-top: 30rpx;
			padding-right: 30rpx;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			color: #0066ff;
			text-decoration: underline;
			.icon{
				font-size: 34rpx;
			}
		}
		.select_box{
			padding: 0 5%;
			display: flex;
			align-items: center;
			padding-top: 30rpx;
			.icon{
				font-size: 60rpx;
			}
			.txt{
				font-size: 34rpx;
				padding: 0 30rpx;
				flex: 1;
				color: #333;
				font-weight: bold;
			}
			.icon2{
				font-size: 50rpx;
				color: #bababa;
			}
			.icon_s{
				color: #4d726f !important;
				font-weight: bold;
			}
			.ali{
				color: #01aaef;
			}
			.bank{
				color: #0066ff;
			}
		}
	}

	.pay-content {
		width: 690rpx;
		background-color: #ffffff;
		box-shadow: 0 0 4rpx 2rpx #f6f6f6;
		border-radius: 20rpx;
		margin: 30rpx auto 0;

		.title {
			font-size: 28rpx;
			font-weight: 500;
			color: #333333;
			padding: 26rpx 0;
			width: 90%;
			margin: 0 auto;
			border-bottom: 1px solid #eeeeee;
		}

		.body {
			width: 90%;
			margin: 0 auto;
			background-color: #ffffff;

			.pay-item {
				height: 100rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.left {
					display: flex;
					align-items: center;

					view {
						&:nth-child(1) {
							width: 60rpx;
							height: 60rpx;
							text-align: center;
							line-height: 60rpx;
							font-size: 44rpx;
						}

						&:nth-child(2) {
							font-size: 24rpx;
							font-weight: 500;
							color: #333333;
							margin-left: 20rpx;
						}
					}

					.iconweixin1 {
						color: #3dcc32;
					}

					.iconzhifubao {
						color: #01aaef;
					}

					.iconyinhangqia {
						color: #fccf00;
					}
				}

				.right {
					width: 50rpx;
					height: 50rpx;
					border: 1px solid #ececec;
					border-radius: 50%;
				}

				.icondagouwancheng {
					font-size: 50rpx;
					color: #ffdb4e;
					border: none;
				}
			}
		}
	}

	.btn {
		width: 690rpx;
		height: 108rpx;
		background: #4d726f;
		color: #fff;
		font-size: 4vw;
		border-radius: 54rpx;
		text-align: center;
		line-height: 108rpx;
		position: fixed;
		bottom: 30rpx;
		left: 50%;
		transform: translate(-50%, 0);
	}

	.list_box {
		width: 92%;
		padding: 10px 0;
		background-color: #fff;
		margin: 0 auto;
		margin-top: 20px;
		border-radius: 6px;
		box-shadow:  0 0 10rpx #dddddd; 
	}

	.list_box .list {
		width: 90%;
		margin: 0 auto;
		position: relative;
	}

	.list_box .list .title {
		width: 100%;
		height: 30px;
		line-height: 30px;
		color: #333;
		font-size: 12px;
	}

	.list_box .list input {
		width: 100%;
		height: 30px;
		line-height: 30px;
		color: #333;
		font-size: 12px;
	}

	.list_box .list .arrow {
		font-size: 14px;
		color: #666;
		line-height: 30px;
		position: absolute;
		right: 0;
		bottom: 15px;
	}
</style>
